AreaFunc = function(a) {
	this.areaFunc = a.toUpperCase();
	this.initFunc();
};
AreaFunc.prototype = {
	areaFunc : "",
	operators : [],
	params : [],
	isReg : false,
	regTest : /^(\(*([A-Z]|(\d*\.?\d*))\)*[\*|\+|\-|\/])*\(*[A-Z]|(\d*\.?\d*)\)*$/,
	initFunc : function()// 将标点和数字分离。
	{
		this.operators = [];
		this.params = [];
		if (!this.regTest.test(this.areaFunc))
			return false;
		else
			this.isReg = true;
		var A = this.areaFunc.split("");

		if (A.length < 1) {
			this.isReg = false;
			return;
		}
		var C = -1;
		for (var B = 0; B < A.length; B++) {
			if (A[B] == '(' || A[B] == ')' || A[B] == '-' || A[B] == '+'
					|| A[B] == '*' || A[B] == '/') {
				this.operators.push(A[B]);
				if (C != -1) {
					this.params.push(this.areaFunc.substring(C, B));
				}
				C = -1;
			} else if (A[B] >= 'A' && A[B] <= 'Z') {
				if (C == -1)
					C = B;
			} else if (A[B] >= '0' && A[B] <= '9') {
				if (C == -1)
					C = B;
			} else if (A[B] == '.') {
				if (C == -1)
					C = B;
			} else {
				this.isReg = false;
				return;
			}
		}

		this.params.push(this.areaFunc.substring(C, A.length));

	},
	isSuccess : function() {
		return this.isReg;
	},
	destroy : function() {
		this.operators = null;
		this.params = null;
	},
	doAction : function(A) {
		var B = this.parse(A);
		var D = [];
		for (var C = 0; C < this.params.length; C++) {
			if (this.params[C] >= 'A' && this.params[C] <= 'Z')
				D.push(B[this.params[C].charCodeAt() - "A".charCodeAt()]);
			else
				D.push(this.params[C]);
		}
		var E = this.outFunc(this.operators, D);
		return eval(E);
	},
	parse : function(A) {
		// 将规格解析成为参数数组
		var B = [];
		var C = A.split("");
		var E = -1;
		for (var D = 0; D < C.length; D++) {
			if (C[D] >= '0' && C[D] <= '9') {
				if (E == -1)
					E = D;
				continue;
			} else if (C[D] == '.') {
				continue;
			} else {
				if (E != -1) {
					B.push(A.substring(E, D));
					E = -1;
				}
			}

		}
		B.push(A.substring(E, C.length));
		return B;
	},
	outFunc : function(D, E) {
		var R = "";
		var B = 0;
		var C = 0;
		var A = 0;
		if (D == null)
			D = this.operators;
		if (E == null)
			E = this.params;
		var F = -1;
		for (A = 0; A < D.length; A++) {

			if (D[A] == '(')
				R += D[A];
			else if (D[A] == ')') {
				R += E[C++];
				R += D[A];
				while(++A<D.length)
				{
					R+=D[A];
					if(D[A]!=')')
						{
							break;
						}
				}
			} else {
				R += E[C++];
				R += D[A];			
			}
		}
		if (C < E.length)
			R += E[C];
		return R;
	}
};